//
// Created by baoch on 2024/12/18.
//
#include <stdio.h>
#include<stdlib.h>
struct DIAN//定义一个结构体
{
    int data;
    struct DIAN* next;
};
struct DIAN* HEAD()//申请头节点
{
    struct DIAN* head = (struct DIAN*)malloc(sizeof(struct DIAN));
    head -> data = 0;
    head -> next = NULL;
    return head;
}
int main()
{
    int n,i;
    scanf("%d %d",&n,&i);
    struct DIAN* head = HEAD();
    struct DIAN* p = head;
    for(int j = 0;j < n;j++)//循环输入链表数据
    {
        struct DIAN* new = (struct DIAN*)malloc(sizeof(struct DIAN));
        scanf("%d ",&(new -> data));
        new -> next = NULL;
        p -> next = new;
        p = p -> next;
    }
    p = head -> next;
    for(int j = 1;j < i;j++)//循环寻找要插入的位置
    {
        p = p -> next;
    }
    struct DIAN* nnew = (struct DIAN*)malloc(sizeof(struct DIAN));//插入新节点
    nnew -> data = i;
    nnew -> next = p -> next;
    p -> next = nnew;
    struct DIAN* tail = head -> next;//重新定义一个指针变量用于循环打印链表
    while(tail != NULL)
    {
        printf("%d ",tail -> data);
        tail = tail -> next;
    }
    return 0;
}